package logic

import (
	"context"
	"src/models/mysql"

	"src/internal/svc"
	"src/src"

	"github.com/zeromicro/go-zero/core/logx"
)

type RegisterListLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewRegisterListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *RegisterListLogic {
	return &RegisterListLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

func (l *RegisterListLogic) RegisterList(in *src.RegisterListRequest) (*src.RegisterListResponse, error) {
	// todo: add your logic here and delete this line

	var register []mysql.Account
	mysql.DB.Debug().Where("status like ?", "%"+in.Status+"%").Find(&register)

	var slice []*src.RegisterListStruct

	for _, listStruct := range register {
		lists := src.RegisterListStruct{
			Tel:      listStruct.Tel,
			Password: listStruct.Password,
			Status:   listStruct.Status,
		}
		slice = append(slice, &lists)
	}

	return &src.RegisterListResponse{Registerlist: slice}, nil
}
